<template>
  <div class="content-box">
    <nav-title title="异动审批" :routerLink="routerLink" />
    <!-- 发起人基本信息 -->
    <div class="regulations-box">
      <div class="title">发起人基本信息</div>
      <div class="information">
        <simple-line title="员工ID" v-bind:value="baseInfo.cWfEmplid" />
        <simple-line title="姓名" v-bind:value="baseInfo.cWfName" />
        <simple-line title="部门" v-bind:value="baseInfo.cWfDeptdescr" />
        <simple-line title="岗位" v-bind:value="baseInfo.cWfJcDescr" />
        <simple-line title="职等" v-bind:value="baseInfo.cWfJobLevel" />
        <simple-line title="导师" v-bind:value="baseInfo.cEmplid2Name" />
        <!-- <simple-line title="入职日期" v-bind:value="baseInfo.cWklifBgnDt2 | dateFormat"/> -->
        <simple-line title="联系电话" v-bind:value="baseInfo.cWfPhone" />
        <simple-line title="申请日期" v-bind:value="baseInfo.cWfAppDt | dateFormat" />
        <simple-line title="岗位性质" v-bind:value="baseInfo.cJobType2" />
      </div>
    </div>

    <!-- 基本信息 -->
    <div class="regulations-box">
      <div class="title">异动者信息</div>
      <simple-line title="异动员工" v-bind:value="baseInfo.nameDisplay" />
      <simple-line title="性别" v-bind:value="baseInfo.sexValue" />
      <simple-line title="入职日期" v-bind:value="baseInfo.lastHireDt | dateFormat" />
      <simple-line title="职等" v-bind:value="baseInfo.rsJobLevel" />
      <simple-line title="专业" v-bind:value="baseInfo.cMajor" />
      <simple-line title="学历" v-bind:value="baseInfo.highestEducLvlValue" />
      <simple-line title="异动前部门" v-bind:value="baseInfo.detpDescr" />
      <simple-line title="异动前岗位" v-bind:value="baseInfo.jobcodeDescr" />
    </div>

    <!-- 调动前信息 -->
    <div class="regulations-box">
      <div class="title">流程信息</div>
      <!-- <simple-line title="异动生效日期" v-bind:value="baseInfo.cXfrDt | dateFormat" /> -->
      <edit-date-line label="异动生效日期" :important="true" :readonly="!editVal['cXfrDt']" :boldtitle="true" v-model="baseInfo.cXfrDt"></edit-date-line>
      <!-- <simple-line title="异动类型" v-bind:value="baseInfo.rsContChgTypeValue"/> -->
      <edit-option-line label="异动原因" :editting="editVal['actionReason']" :vals="xfrReasons" :boldtitle="true" v-model="baseInfo.actionReason" />
      <!-- <simple-line title="异动原因" v-bind:value="baseInfo.actionReasonValue" /> -->
      <simple-line title="异动后部门" v-bind:value="baseInfo.cXfrDeptdescr" />
      <simple-line title="异动后岗位" v-bind:value="baseInfo.cXfrJobcodeDesc" />
      <simple-line title="异动后岗位职等" v-if="displayVal['cXfrJoblevel']" v-bind:value="baseInfo.cXfrJoblevel" />
      <simple-line title="异动后晋升职等" v-if="displayVal['cXfrJoblevelP']" v-bind:value="baseInfo.cXfrJoblevelP" />
      <simple-line title="异动后直接上级" v-model="baseInfo.cXfrSupervisor" :editting="true" />
      <simple-line title="跨法人公司异动" v-bind:value="baseInfo.cXfrRecontract == 'Y' ? '是' : '否'" />
      <div v-if="leaveReasonShow">
        <simple-line title="近一次绩效" v-bind:value="baseInfo.cFdJxjg" />
        <simple-line title="是否转正" v-bind:value="baseInfo.cYesno2 == 'Y' ? '是' : '否'" />
        <simple-line title="是否优化备案人员" v-bind:value="baseInfo.cTerIsSfyhbary == 'Y' ? '是' : '否'" />
      </div>
      <simple-line title="其他说明" v-bind:value="baseInfo.cOtherExplain" />

      <file-line v-if="!edit" label="附件" :fileitems="baseInfo.wfFiles" :boldtitle="true" />
    </div>

    <div class="regulations-box">
      <div class="title">分权引用</div>
      <fqyy-line :editting="false" :fqyyFlag="fqyyInfo.cFqyyFlag" :noFqyySum="fqyyInfo.noFqyySum" :noFqyyRatio="fqyyInfo.noFqyyRatio"
        :fqyyMsg="fqyyInfo.cFqyyDetail" ref="fqyy"></fqyy-line>
    </div>

    <!-- 流程图 -->
    <div class="regulations-box">
      <div class="title">流程图</div>
      <v-flow-charts :transNum="cTransactionNbr" :loginOprid="loginOprid"></v-flow-charts>
    </div>

    <!-- 审批意见 -->
    <div class="regulations-box" v-if="approved == '0'&&baseInfo.cStepType!='C' && baseInfo.cIsChuanyue != 'Y'">
      <div class="info-label">审批意见</div>
      <div class="info-label-text">
        <textarea v-if="approved == '0'" placeholder="请在这里输入..." rows="5" v-model="cComments"></textarea>
        <textarea v-else="" readonly rows="5" v-model="cComments"></textarea>
      </div>
    </div>



    <div style="height: 50px"></div>
    <!-- 底部按钮 -->
    <div v-if="approved == '0'">
      <operation-btn :cApprovalSw="baseInfo.cApprovalSw" :cDenySw="baseInfo.cDenySw" :cPushbackAllSw="baseInfo.cPushbackAllSw"
        :cAddSw="baseInfo.cAddSw" :cTransactionNbr="baseInfo.cTransactionNbr" :cWfType="baseInfo.cWfType"
        :approveBizType="'mobilization'" :cReadSw="baseInfo.cIsChuanyue" :cStepType="baseInfo.cStepType" :cComments="cComments"
        :getBizParams="getBizParams"></operation-btn>
    </div>
  </div>
</template>
<script>
  import { dateFormat, Selector, Datetime, Group, PopupPicker, PopupRadio } from "vux";
import {
  getXfrReasons,
  getMobilization,
  getCompensateApprove,
  getFqyyInfo
} from "../../api/api";
import fqyyLine from "../../components/basic/FqyyLine"
import { json2Form, publicUrl } from "../../util/http";
import vBaseInfo from "../formalStaff/baseInfo";
import EditDateLine from '../../components/basic/EditDateLine'
import EditOptionLine from '../../components/basic/EditOptionLine'
import FileLine from '../../components/basic/FileLine'
import operationBtn from "./common/operationBtn";
import vFlowCharts from "../formalStaff/common/flowChart";
import SimpleLine from '../../components/basic/SimpleLine'
import CommonUtil from '../../components/basic/util'

export default {
  name: "guide-to",
  components: {
    Group,
    Selector,
    Datetime,
    PopupPicker,
    PopupRadio,
    operationBtn,
    vFlowCharts,
    vBaseInfo,
    SimpleLine,
    EditDateLine,
    EditOptionLine,
    FileLine,
    fqyyLine
  },
  created() {

  },
  mounted() {
    CommonUtil.tryLogin(this).then(()=>{
      this.cTransactionNbr = this.$route.query.cTransactionNbr;
      this.approved = this.$route.query.approved;
      this.loginOprid = this.$route.query.token;
      if (this.$route.query.approved == "0") {
        this.routerLink = "/todoList/todo";
      } else {// if (this.$route.query.approved == "1") {
        this.routerLink = "/todoList/done";
      }
      //工作调动审批审批信息
      this.getMobilizationInfo();
      CommonUtil.loadDic(this.jobcodeLevels, 'C_PFQ_TYPE', "xlatshortname","fieldvalue");//职等字典
      this.loadReasons();
    })
  },
  data() {
    return {
      fqyyInfo:{
        fqyyFlag:'',
        fqyyDetail:''
      },
      jobcodeLevels: [],
      showItem: {},
      showDetail: false,

      cTransactionNbr:'',
      loginOprid:'',
      approved: "0",


      //返回需要跳转到哪个页面
      routerLink: "",
      //是否从已审批页面跳转过来

      //发起人基本信息
      baseInfo: {},


      ynVal:[{ value: "是", key: "Y" }, { value: "否", key: "N" }],
      xfrReasons:[],
      //按钮点击的参数
      cComments: "",
      displayVal:{},
      editVal:{},
      leaveReasonShow:false
    };
  },
  methods: {
    showItemClick(item) {
      this.showItem = item;
      this.showDetail = true;
    },
    hiddenImg() {
      this.showDetail = false;
    },
    loadReasons() {
      var _this = this;
      getXfrReasons().then(
        res => {
          if (res && res.retCode === "000000") {
            res.retData.forEach(function(r){
              _this.xfrReasons.push({key:r[0],value:r[1]});
            })
          }
          console.error(_this.xfrReasons)

        }
      )
    },
    getMobilizationInfo() {
      this.$vux.loading.show();
      let params = {
        cTransactionNbr: this.cTransactionNbr,
        loginOprid: this.loginOprid
      };
      getMobilization(params)
        .then(res => {
          this.$vux.loading.hide();
          if (res && res.retCode === "000000") {
            getFqyyInfo({'cTransactionNbr':this.cTransactionNbr,'processType':'mobilization'}).then(res => {
                this.fqyyInfo = res.retData;
            })

            //发起人信息
            this.baseInfo = res.retData;
             // console.log(this.baseInfo.emplid);
             // console.log(this.$store.state.eid);
            if(this.$store.state.eid!=null && this.baseInfo.emplid!=null && this.baseInfo.emplid != this.$store.state.eid){
              if(this.baseInfo.cWfAppDt > new Date('2020-2-28 23:59:59').getTime()){
                this.leaveReasonShow = true;
              }

              // console.log('111');
            }
            CommonUtil.updateFileUrl(this.baseInfo.wfFiles);
            //审批信息
            this.cTransactionNbr = res.retData.cTransactionNbr;
            let auths = this.baseInfo.authFileds;
            for(var i=0;i<auths.length;i++) {
              this.displayVal[auths[i].fieldKey] = auths[i].isDisplay
              this.editVal[auths[i].fieldKey] = auths[i].isEdit
            }
          } else {
            this.$vux.loading.hide();
            this.$vux.alert.show({
              title: "提示",
              content: res.retMsg
            });
          }
        })
        .catch(res => {
          this.$vux.alert.show({
            title: "警告",
            content: "网络异常，请稍后重试"
          });
        });
    },
    getBizParams(){
      var _this = this;
      var params = {};
      Object.keys(_this.editVal).forEach(function(key){
        if(key && _this.editVal[key]) {
          params[key] = _this.baseInfo[key]
        }
      });
      return params;
    }
  }
};
</script>

<style type="text/scss" lang="scss">
  @import "../../styles/staff.scss";
</style>
